<?php

/**
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
$api = app('Dingo\Api\Routing\Router');

/**
 * add in header    Accept:application/vnd.lumen.v1+json
 * @var TYPE_NAME $api
 */
$api->version('v1', ['namespace' => 'App\Http\Controllers\Api'], function ($api) {

    /****在以下组里请模块名进行分组 跨域****/
    $api->group(['middleware' => 'cors'], function ($api) {

        // Auth login
        $api->post('authorizations', ['as' => 'authorizations.store', 'uses' => 'AuthController@login']);

        /****在以下组里请模块名进行分组 登录用户组****/
        $api->group(['middleware' => 'api.auth'], function ($api) {
            //token刷新
            $api->put('authorizations', ['as' => 'authorizations.refresh', 'uses' => 'AuthController@refresh']);
            //token删除和登出
            $api->delete('authorizations', ['as' => 'authorizations.logout', 'uses' => 'AuthController@logout']);

//            $api->post('myself', ['as' => 'authorizations.myself', 'uses' => 'AuthController@myself']);

            /****公共接口****/
            $api->get('common/oss/sts',['as'=>'common.oss.sts','uses'=>'CommonController@getAliOssSts']);
            //首页部分统计
            $api->get('common/statistics',['as'=>'common.statistics','uses'=>'CommonController@getHomeStatistics']);

            /****附件管理****/
            // 附件修改接口
            $api->put('attachment/{id}', 'AttachmentController@update');
            //添加附件
            $api->post('attachment', ['as' => 'attachment.create', 'uses' => 'AttachmentController@store']);
            //附件详情
            $api->get('attachment', ['as' => 'attachment.show', 'uses' => 'AttachmentController@show']);
            //删除附件
            $api->delete('attachment', ['as' => 'attachment.delete', 'uses' => 'AttachmentController@destroy']);

            /****用户相关****/
            $api->group(['namespace'=>'Member'], function ($api){
                //获取当前登录用户基础信息
                $api->get('user/current', 'UserController@current');
                //获取用户列表
                $api->get('user/page', 'UserController@userPage');
                //获取用户实名认证信息
                $api->get('user/authentication/{id}', 'UserController@getUserAuthentication');
                //删除用户
                $api->delete('user', 'UserController@deleteUser');
                //恢复被删除用户
                $api->patch('user/recovery', 'UserController@recoveryUser');

                /****用户认证列表相关****/
                //认证列表分页列表
                $api->get('user/authentication', 'UserInfoController@getUserAuthenticationPage');

                /****用户收货列表相关****/
                //获取用户地址列表
                $api->get('user/address', 'UserInfoController@getUserAddressPage');

                /****用户登录日志相关****/
                //获取用户登录日志列表
                $api->get('user/log/page', 'UserLoginLogController@userLoginLogPage');

                /****管理员相关****/
                //获取管理员列表
                $api->get('manage/page', 'UserController@manageUserPage');
                //获取单条数据详细信息
                $api->get('manage/single', 'UserController@managerSingle');
                //编辑管理员
                $api->patch('manage', 'UserController@updateManageUser');
                //新增管理员
                $api->post('manage', 'UserController@addManageUser');
                //软删除管理员
                $api->delete('manage', 'UserController@deleteManageUser');
            });

            /****权限路由相关****/
            //获取权限路由列表
            $api->get('permission/routing/pages', ['as' => 'permission.pages.get', 'uses' => 'Permission\PermissionController@pagesRouting']);
            //添加权限路由
            $api->post('permission/routing', ['as' => 'permission.post', 'uses' => 'Permission\PermissionController@addRouting']);
            //修改权限路由
            $api->patch('permission/routing', ['as' => 'permission.patch', 'uses' => 'Permission\PermissionController@updateRouting']);
            //删除权限路由
            $api->delete('permission/routing', ['as' => 'permission.delete', 'uses' => 'Permission\PermissionController@deleteRouting']);
            //获取所有列表
            $api->get('permission/routing/choice', ['as' => 'permission.choice.get', 'uses' => 'Permission\PermissionController@choice']);
            //获取单条数据详细信息
            $api->get('permission/routing/single', ['as' => 'permission.single.get', 'uses' => 'Permission\PermissionController@single']);
            //获取单条权限路由数据
            $api->get('permission/routing/structure', ['as' => 'permission.structure.get', 'uses' => 'Permission\PermissionController@structure']);

            /****角色相关****/
            //获取角色列表
            $api->get('role/pages', ['as' => 'role.pages.get', 'uses' => 'Permission\RoleController@rolePages']);
            //删除角色
            $api->delete('role', ['as' => 'role.delete', 'uses' => 'Permission\RoleController@delete']);
            //添加角色
            $api->post('role', ['as' => 'role.post', 'uses' => 'Permission\RoleController@add']);
            //添加角色
            $api->patch('role', ['as' => 'role.patch', 'uses' => 'Permission\RoleController@update']);
            //获取所有角色列表
            $api->get('role/list', ['as' => 'role.list.get', 'uses' => 'Permission\RoleController@roleList']);

            /****商品相关****/
            //获取商品分类列表
            $api->get('category/list', ['as' => 'category.list.get', 'uses' => 'Shop\GoodsController@getCategoryList']);
            //获取商品分类分页列表
            $api->get('category/page', ['as' => 'category.page.get', 'uses' => 'Shop\GoodsController@getCategoryPage']);
            //获取分类信息详情
            $api->get('category/detail', ['as' => 'category.detail.get', 'uses' => 'Shop\GoodsController@goodsCategoryDetail']);
            //添加分类
            $api->post('category', ['as' => 'category.post', 'uses' => 'Shop\GoodsController@addGoodsCategory']);
            //更新分类
            $api->patch('category', ['as' => 'category.patch', 'uses' => 'Shop\GoodsController@updateGoodsCategory']);
            //更新分类
            $api->delete('category', ['as' => 'category.delete', 'uses' => 'Shop\GoodsController@deleteGoodsCategory']);
            //更新显示状态
            $api->patch('category/status', ['as' => 'category.status.patch', 'uses' => 'Shop\GoodsController@updateStatusGoodsCategory']);
            //添加商品分类列表
            $api->patch('category/recommend', ['as' => 'category.recommend.patch', 'uses' => 'Shop\GoodsController@updateRecommendGoodsCategory']);
            //添加商品
            $api->post('goods', ['as' => 'goods.post', 'uses' => 'Shop\GoodsController@addGoods']);
            //添加商品
            $api->put('goods/status', ['as' => 'goods.status.put', 'uses' => 'Shop\GoodsController@updateGoodsStatus']);
            //删除商品
            $api->delete('goods', ['as' => 'goods.delete', 'uses' => 'Shop\GoodsController@deleteGoods']);
            //获取商品分页列表
            $api->get('goods/page', ['as' => 'goods.page.get', 'uses' => 'Shop\GoodsController@getGoodsPage']);
            //获取商品详细信息
            $api->get('goods/detail', ['as' => 'goods.detail.get', 'uses' => 'Shop\GoodsController@getGoodsDetail']);
            //获取商品分页列表
            $api->get('goods/sku/{id}', ['as' => 'goods.sku.get', 'uses' => 'Shop\GoodsController@getGoodsSku']);
            //更新商品分页列表
            $api->patch('goods/sku', ['as' => 'goods.sku.patch', 'uses' => 'Shop\GoodsController@updateGoodsSku']);

            /****Banner相关****/
            //获取商品分页列表
            $api->get('banner/page', ['as' => 'banner.page.get', 'uses' => 'Shop\BannerController@getBannerPage']);
            //获取banner详情
            $api->get('banner/detail', ['as' => 'banner.detail.get', 'uses' => 'Shop\BannerController@bannerDetail']);
            //新增banner
            $api->post('banner', ['as' => 'banner.post', 'uses' => 'Shop\BannerController@addBanner']);
            //编辑banner
            $api->patch('banner', ['as' => 'banner.patch', 'uses' => 'Shop\BannerController@editBanner']);
            //修改banner的状态
            $api->patch('banner/status', ['as' => 'banner.status.patch', 'uses' => 'Shop\BannerController@updateStatus']);
            //删除banner
            $api->delete('banner', ['as' => 'banner.delete', 'uses' => 'Shop\BannerController@deleteBanner']);

            /****拍卖规则相关****/
            //获取rule分页列表
            $api->get('auctionRule/page', ['as' => 'auctionRule.page.get', 'uses' => 'Shop\AuctionRuleController@getAuctionRulePage']);
            //删除拍卖规则
            $api->delete('auctionRule/delete', ['as' => 'auctionRule.delete.delete', 'uses' => 'Shop\AuctionRuleController@deleteAuctionRuleById']);
            //更新拍卖规则
            $api->patch('auctionRule/update', ['as' => 'auctionRule.update.patch', 'uses' => 'Shop\AuctionRuleController@updateAuctionRule']);
            //更新拍卖规则状态
            $api->patch('auctionRule/updataStatus', ['as' => 'auctionRule.updataStatus.patch', 'uses' => 'Shop\AuctionRuleController@updateAuctionRuleStatus']);
            //增加拍卖规则
            $api->post('auctionRule/add', ['as' => 'auctionRule.add.post', 'uses' => 'Shop\AuctionRuleController@addAuctionRule']);

            /****供应商相关****/
            //获取rule分页列表
            $api->get('supplier/page', ['as' => 'supplier.page.get', 'uses' => 'Shop\SupplierController@getSupplierPage']);
            //删除供应商
            $api->delete('supplier/delete', ['as' => 'supplier.delete.delete', 'uses' => 'Shop\SupplierController@deleteSupplierById']);
            //更新供应商
            $api->patch('supplier/update', ['as' => 'supplier.update.patch', 'uses' => 'Shop\SupplierController@updateSupplier']);
           //增加供应商
            $api->post('supplier/add', ['as' => 'supplier.add.post', 'uses' => 'Shop\SupplierController@addSupplier']);

            /****订单相关****/
            //获取订单列表
            $api->get('order/page', ['as' => 'order.page.get', 'uses' => 'Shop\OrderController@getOrderPage']);
            //订单详情
            $api->get('order/detail/{id}', ['as' => 'order.detail.get', 'uses' => 'Shop\OrderController@getOrderDetail']);
            //订单详情
            $api->get('region/list', ['as' => 'region.list.get', 'uses' => 'Shop\OrderController@regionList']);
            //订单详情
            $api->get('carrier/list', ['as' => 'carrier.list.get', 'uses' => 'Shop\OrderController@getCarrierList']);
            //订单发货
            $api->patch('order/delivery', ['as' => 'order.delivery.get', 'uses' => 'Shop\OrderController@deliverOrder']);
            //获取物流数据
            $api->get('ship/list', ['as' => 'ship.list.get', 'uses' => 'Shop\OrderController@shipDetails']);
            //更新收货信息
            $api->patch('order/receiver', ['as' => 'order.receiver.patch', 'uses' => 'Shop\OrderController@updateReceiver']);

            /****短信配置相关****/
            //短信配置分页列表
            $api->get('sms/setting/page', ['as' => 'sms.setting.page.get', 'uses' => 'SmsController@settingSmsPage']);
            //删除短信配置
            $api->delete('sms/setting', ['as' => 'sms.setting.delete', 'uses' => 'SmsController@deleteSettingSms']);
            //编辑短信配置
            $api->patch('sms/setting', ['as' => 'sms.setting.patch', 'uses' => 'SmsController@updateSettingSms']);
            //添加短信配置
            $api->post('sms/setting', ['as' => 'sms.setting.post', 'uses' => 'SmsController@addSettingSms']);
            //短信配置详情
            $api->get('sms/setting/detail', ['as' => 'sms.setting.detail.get', 'uses' => 'SmsController@getSettingSmsDetail']);
            //保存默认的短信配置
            $api->patch('sms/setting/default', ['as' => 'sms.setting.default', 'uses' => 'SmsController@settingDefaultSms']);
            //获取用户短信列表
            $api->get('user/sms/log', ['as' => 'user.sms.log.get', 'uses' => 'SmsController@getSmsLogPage']);
            //群发短信
            $api->post('sms/send/group', ['as' => 'sms.send.group.post', 'uses' => 'SmsController@sendUserSms']);
            //获取默认短信配置
            $api->get('sms/default/sms', ['as' => 'user.default.sms', 'uses' => 'SmsController@getDefaultSms']);
            //获取群发短信列表
            $api->get('user/group/sms', ['as' => 'user.group.sms.get', 'uses' => 'SmsController@getGroupSmsPage']);
            //获取群发短信列表详情
            $api->get('user/group/sms/log', ['as' => 'user.group.sms.log.get', 'uses' => 'SmsController@getGroupSmsLogPage']);
            //群发短信
            $api->post('sms/send/again', ['as' => 'sms.send.again.post', 'uses' => 'SmsController@againSendSingleSms']);

            /****用户支付相关****/
            //用户资金消费明细列表
            $api->get('pay/amount/page', ['as' => 'pay.amount.page.get', 'uses' => 'Shop\PayController@userAmountPage']);
            //用户积分明细列表
            $api->get('pay/integral/page', ['as' => 'pay.integral.page.get', 'uses' => 'Shop\PayController@userIntegralPage']);
            //用户提现明细列表
            $api->get('pay/withdraw/page', ['as' => 'pay.withdraw.page.get', 'uses' => 'Shop\PayController@userWithdrawPage']);

            /****系统配置相关****/
            //微信配置保存
            $api->post('setting/weChat', ['as' => 'setting.weChat.post', 'uses' => 'SystemController@weChatSetting']);
            //获取微信配置
            $api->get('setting/weChat', ['as' => 'setting.weChat.get', 'uses' => 'SystemController@getWeChatSetting']);
            //保存阿里第三方配置
            $api->post('setting/ali', ['as' => 'setting.ali.post', 'uses' => 'SystemController@aliSetting']);
            //获取阿里第三方配置
            $api->get('setting/ali', ['as' => 'setting.ali.get', 'uses' => 'SystemController@getAliSetting']);
            //保存与订单和拍卖有关的配置参数
            $api->post('setting/auction', ['as' => 'setting.auction.post', 'uses' => 'SystemController@auctionSetting']);
            //获取与订单和拍卖有关的配置参数
            $api->get('setting/auction', ['as' => 'setting.auction.get', 'uses' => 'SystemController@getAuctionSetting']);
            //保存OSS配置
            $api->post('setting/oss', ['as' => 'setting.oss.post', 'uses' => 'SystemController@ossSetting']);
            //获取OSS配置参数
            $api->get('setting/oss', ['as' => 'setting.oss.get', 'uses' => 'SystemController@getOssSetting']);

            /****系统相关****/
            //拍卖纪录列表
            $api->get('failed/page', ['as' => 'failed.page.get', 'uses' => 'SystemController@getFailedJobsPage']);

            /****拍卖相关****/
            //拍卖纪录列表
            $api->get('auction/record/page', ['as' => 'auction.record.page.get', 'uses' => 'Auction\AuctionController@auctionRecordPage']);
            //拍卖纪录商品列表
            $api->get('auction/goods/page', ['as' => 'auction.goods.page.get', 'uses' => 'Auction\AuctionController@auctionGoodsPage']);

        });
    });
});
